package wahadlo.nowe.utils;

import wahadlo.nowe.math.Function;
import wahadlo.nowe.math.Location;
import wahadlo.nowe.math.Speed;
import wahadlo.nowe.model.Model;

public class FunctionFactory {

	public static Function getFunction(String chartType, Model model) {
		Function f = null;
		if (chartType.equals("inclination_t")) {
			Double length = (Double) model.getProperties().get("length");
			Double beta = (Double) model.getProperties().get("forcing");
			Double inclination = (Double) model.getProperties().get(
					"inclination");
			Double a0 = length * (1 - Math.cos(inclination));
			f = new Location(a0, beta, length, inclination);
		}
		else if(chartType.equals("speed_t")){
			Double length = (Double) model.getProperties().get("length");
			Double beta = (Double) model.getProperties().get("forcing");
			Double inclination = (Double) model.getProperties().get(
					"inclination");
			Double a0 = length * (1 - Math.cos(inclination));
			f = new Speed(a0, beta, length);
		}
		return f;
	}

}
